import datetime
import json
import time


def stringify(data):
    return json.dumps(data, ensure_ascii=False, separators=(',', ':'))


def timestampToTime(timestamp):
    timeStruct = time.localtime(timestamp)
    return time.strftime('%Y-%m-%d %H:%M:%S', timeStruct)


def timeStrToTimeStamp(timeStr: str) -> float:
    x = time.strptime(timeStr, '%Y-%m-%d %H:%M:%S')
    return time.mktime(x)


def timeStampToDateTime(timestamp):
    return datetime.datetime.fromtimestamp(timestamp)
